<?php

namespace App\Policies;

use App\Models\User;
use App\Models\Reply;

class ReplyPolicy extends Policy
{
    public function update(User $user, Reply $reply)
    {
        return $reply->user_id == $user->id;
    }

    /**
     * 删除评论： 作者 和 用户自己
     * @param User $user
     * @param Reply $reply
     *
     * @return bool
     * @data 2022/11/9
     * @author fanzhaogui
     */
    public function destroy(User $user, Reply $reply)
    {
        return ($reply->topic->user_id == $user->id || $reply->user_id == $user->id);
    }
}
